package club.wx3609.images.service;

import club.wx3609.images.entity.Message;
import club.wx3609.images.interfaces.repository.MessageRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MessageService {

    @Resource
    private MessageRepository messageRepository;

    public Message addMessage(Message message){
        return messageRepository.save(message);
    }
    public List<Message> findBySender(String sender){
        return messageRepository.findBySender(sender);
    }
    public List<Message> findByReceiver(String receiver){
        return messageRepository.findByReceiver(receiver);
    }
    public List<Message> findAll(){
        return  messageRepository.findAll();
    }
}
